import { useEffect, useState } from 'react'
import axios from 'axios'
import Address from './Address'
import { func } from 'prop-types'


// function App() {
//   const [address, setAddress] = useState([])
//   // const [showDialog, setShowDialog] = useState(false)

//   useEffect(function() {
//     async function getUserAddress() {
//       const {data} = await axios.get('https://www.fastmock.site/mock/ecde49edeca24af1021f56f686193a45/beers/address')
//       console.log(data)
//       if (data && data.length>0) {
//         setAddress([...data])
//       }
//     }
//     getUserAddress()
//     // console.log('+++++++++++++')
//     // (async function() {

//     // })()
//   }, [])
//   return (
//     <div>
//       <Address address={address}/>
//     </div>
//   )
// }

function App() {
  const [address, setAddress] = useState([])

  useEffect(function() {
    async function getUserAddress() {
      const { data } = await axios.get('https://www.fastmock.site/mock/ecde49edeca24af1021f56f686193a45/beers/address')
      // console.log([...data],'------')
      console.log(data,'---++++')
      if(data && data.length > 0) {
        setAddress(data)
      }
    } 
    getUserAddress();
  },[])
  return (
    <div>
      <Address address={address}/>
    </div>
  )
}
export default App
